package com.itheima.mapper;

import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2022/12/17 15:26
 */
public interface StatMapeer {
    @Select("SELECT\n" +
            " td.dept_name as deptName,COUNT(tu.id) as num\n" +
            "FROM \n" +
            "tb_dept td LEFT JOIN tb_user tu \n" +
            "ON td.id = tu.dept_id\n" +
            "GROUP BY td.dept_name")
    List<Map> columnCharts();

    @Select("select tm.name as monthNames,IFNULL(u.num,0) as num from tb_month tm left join \n" +
            "(select DATE_FORMAT(tu.hire_date,'%m') as 'month', count(tu.id) as num\n" +
            "from tb_user tu group by  DATE_FORMAT(hire_date,'%m')) as u\n" +
            "on tm.name = u.`month`\n" +
            "ORDER BY tm.name asc")
    List<Map> lineCharts();

}
